﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.Areas.Admin.Controllers
{
    /// <summary>
    /// 评议结束
    /// </summary>
    /// 
    [OutputCache(Duration = 0, VaryByParam = "none")]
    public class PeerReviewEndController : Controller
    {
        //
        // GET: /Admin/PeerReviewEnd/

        /// <summary>
        /// 评议结束
        /// </summary>
        /// <returns>视图</returns>
        public ActionResult Index()
        {

            BLL.PeerReview peerReviewBll = new BLL.PeerReview();

            DataSet ds = peerReviewBll.GetIsFtatus();

            string isFstatus = "";
            if (ds.Tables[0].Rows.Count > 0)
            {
                isFstatus = ds.Tables[0].Rows[0]["FStatus"].ToString();
            }
            else
            {
                isFstatus = "";
            }
            ViewData["isFstatus"] = isFstatus;

            return View();
        }

        /// <summary>
        /// 结束的方法
        /// </summary>
        /// <returns></returns>
        public string End()
        {
            string str = "";
            BLL.PeerReview peerReviewBll = new BLL.PeerReview();
            List<Model.PeerReview> peerReviewList = peerReviewBll.GetList();
            decimal peerReviewID = 0;

            foreach (Model.PeerReview Model in peerReviewList)
            {
                peerReviewID = Model.FPeerReviewID;
            }
            try
            {
                Model.PeerReview peerReviewModel = new Model.PeerReview();
                peerReviewModel.FStatus = "E";

                peerReviewBll.End(peerReviewModel, peerReviewID);
                str = "ok";
            }
            catch (Exception)
            {
                str = "error";
            }
            return str;
        }


    }
}
